package org.proddevplm.business.api;

import org.proddevplm.dao.core.DAOManager;

import java.util.Map;

import javax.servlet.http.HttpSession;

public abstract class AController implements IController {

	private Map<String, Object> stateMap;
	private HttpSession session;
    private DAOManager daoManager;

    public DAOManager getDaoManager() {
        if (daoManager == null) {
            daoManager = new DAOManager();
        }
        return daoManager;
    }

    @Deprecated
    public Map<String, Object> getStateMap() {
		return stateMap;
	}
	public void setStateMap(Map<String, Object> stateMap) {
		this.stateMap = stateMap;
	}

    //@Deprecated
    public HttpSession getSession() {
		return session;
	}
	public void setSession(HttpSession session) {
		this.session = session;
	}
	
	public void putOnState(String key, Object value) {
        stateMap.put(key, value);
    }

    public void putOnSession(String key, Object value) {
        session.setAttribute(key, value);
    }
    
    public void removeFromSession(String key){
    	session.removeAttribute(key);
    }
	
}
